<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
	<title>停车场--${headerTitle }</title>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1";/><!-- IE的渲染模式 -->
    <meta name="keywords" content="信帧,teleframe,iparking,I停车,爱停车,blackshadowwalker" />
	<meta name="description" content="信帧,teleframe,iparking,I停车,爱停车,blackshadowwalker" />
	<meta name="author" content="blackshadowwalker" />
    
	<link href="bootstrap/3/css/bootstrap.css" rel="stylesheet"/>

	<script src="scripts/jquery/jquery-1.7.min.js"></script>
	<script src="bootstrap/3/js/bootstrap.min.js"></script>
	<link href="bootstrap/3/css/bootstrap-timepicker.min.css" rel="stylesheet"/>
	<script src="bootstrap/3/js/bootstrap-timepicker.js"></script>
	
	<script src="scripts/validateForm.js?t=123"></script>
	<link href="css/common.css" rel="stylesheet"/>
	
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=15EdmORyQbzDsGOQHiTsW2oh"></script>
	
	<script type="text/javascript">
		var msg = "${msg}";
		if(msg!="")
			alert(msg);
			
	</script>
	
	<style>
		body{
			margin-left: 10px;
			margin-top: 7px;
		}
	</style>

</head>

<body>

<div  >
	
<div id="div-form">

	<div>
		<div class="alert-info" >
			<a href="${action }" class="btn btn-warning">返回</a>
			<div style="display:inline;margin-left:30px;color:#f00;">
				${msg }
			</div>
		</div >
	</div>
	
	<form id="myform" name="myform" class="form-horizontal" role="form"  action="${action }?id=${id}&method=${method}" method="post" >
			
		  <div class="hidden">
			token : <s:token/>
			车场信息来源（1：自己注册；2：外部引入3：合同用户）:<input name="parkInfo.source" value="1"/>	
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span> 停车场名称：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.PName}</label>
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span> 营业编号：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.businessNo }</label>
		    </div>
		  </div>
	     <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>停车场描述：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.PDesc}</label>
		    </div>
		  </div>
		  
	     <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>停车场类型：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.PTypeName}</label>
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label"> 白天单价：</label>
		    <div class="col-sm-5">
		    	<div class="input-group">
			      <input class="form-control" value="${parkInfo.dayPrice }"readonly>
			      <div class="input-group-addon">元，每</div>
			      <input class="form-control"  value="${parkInfo.dayTimeUtil}" readonly>
			      <div class="input-group-addon">小时</div>
			    </div>
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label"> 白天工作时间：</label>
		    <div class="col-sm-5">
		    	<div class="input-group" >
			      <div class="input-group-addon" ><i class="glyphicon ">上班:</i></div>
			      <input class="form-control"  value="${parkInfo.dayStartTime }"
			      		  readonly>
			      <div class="input-group-addon"><i class="glyphicon">下班:</i></div>
			      <input class="form-control" value="${parkInfo.dayEndTime }" 
			      		 readonly>
			    </div>
		    </div>
		  </div>
		  
		  
		  	  <div class="form-group">
		    <label class="col-sm-2 control-label"> 夜间单价：</label>
		    <div class="col-sm-5">
		    	<div class="input-group">
			      <input class="form-control"  name="parkInfo.nightPrice" value="${parkInfo.nightPrice }" readonly="readonly">
			      <div class="input-group-addon">元，每</div>
			      <input class="form-control"  name="parkInfo.nightTimeUtil" value="${parkInfo.nightTimeUtil}" readonly="readonly">
			      <div class="input-group-addon">小时</div>
			    </div>
		    </div>
		  </div>
		  
		    <div class="form-group">
		    <label class="col-sm-2 control-label">夜间工作时间：</label>
		    <div class="col-sm-5">
		    	<div class="input-group" >
			      <div class="input-group-addon" ><i class="glyphicon ">上班:</i></div>
			      <input class="form-control"  value="${parkInfo.nightStartTime }"
			      		  readonly>
			      <div class="input-group-addon"><i class="glyphicon">下班:</i></div>
			      <input class="form-control" value="${parkInfo.nightEndTime }" 
			      		 readonly>
			    </div>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>位置：</label>
		    <div class="col-sm-5">
				<input type="hidden" name="parkInfo.longitude" value="${parkInfo.longitude}"  placeholder="经度" isValidate="true"  notEmpty="false" readonly/> 	
				<input type="hidden" name="parkInfo.latitude" value="${parkInfo.latitude}"  placeholder="纬度" isValidate="true"  notEmpty="false" readonly/>
				<div class="col-sm-5">
		    			<label class="form-control">${parkInfo.addr}</label>
		    </div>
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>车场电话：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.telePhone}</label>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>总车位数：</label>
		     <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.parkNumber}</label>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>剩余车位数：</label>
		     <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.remainderParkNumber}</label>
		    </div>
		  </div>
		  

		  
	      <div class="form-group" name="parkInfo.minGratuity" style="display:none;" >
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>最低小费收取额度：</label>
		     <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.minGratuity}元</label>
		    </div>
		  </div>
		  
		  <div class="form-group" name="parkInfo.enterpriseName">
		    <label class="col-sm-2 control-label"><span style="color:#f00"></span>企业名称：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.enterpriseName}</label>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label   class="col-sm-2 control-label"><span style="color:#f00"></span>车场状态：</label>
		    <div class="col-sm-5">
		    			<label class="form-control">${parkInfo.statusName}</label>
		    </div>
		  </div>
	</form>

</div> <!-- div of form -->


<div id="div-map" style="display:none;">
	<div id="baidumap" style="width:96%;height:500px;">
		 正在加载.....
	</div>
	<a class="btn btn-success" href="javascript:void(0)" id="gobackform">返回</a>
</div>


</div>
		
		
		<script>
				
			$(document).ready(function(){
				
				$("textarea[name='parkInfo.PDesc']").val("${parkInfo.PDesc}");
				
				$("#setpostion").click(function(){
					$("#div-form").animate({
						height: 'toggle', 
						opacity: 'toggle' 
					},1000);
					$("#div-map").show(1000, function(){ });
				});
				$("#gobackform").click(function(){
					$("#div-form").show(1000);
					$("#div-map").slideDown(1000, function(){ 
						$("#div-map").hide();
					});
				});
				
				$("#myform input[type='submit']").click(function(e){
				    e.preventDefault();//阻止提交按钮的默认 action
				//	  alert("Submit prevented");
					if(!$("#myform").validateForm()){
						return ;
					}
					var btn = $(this);
			  		btn.val("正在提交...");
			  		btn.addClass("disabled");
			  		$(btn).parent().children("input[type='reset']").addClass("disabled");
					$("#myform").submit();
				});
				
				//设定时间选择器  url : http://jdewit.github.io/bootstrap-timepicker/index.html  DateTime : http://www.eyecon.ro/bootstrap-datepicker/
				$("input.timepicker").each(function(){
	    			var obj =  $(this);
	    			var defaultval = obj.attr("default");
	    			var val = obj.val();
	    			if(val=="")
	    				val = defaultval;
	    			obj.timepicker({
		                template: 'dropdown', //false | 'dropdown' | 'modal'
		                showInputs: true,
		                minuteStep: 5,
		                showMeridian: false,
		                disableFocus: false,
		                defaultTime: val
		            });
		            obj.click(function() {//点击此timepicker时，先关闭所有的timepicker，在开启此timepicker
		            	$("input.timepicker").each(function(){
		            		$(this).timepicker('hideWidget');
		            	});
		            	$(this).timepicker('showWidget');
					});
	    		});
	    		
	    		//百度地图
	    		setTimeout(function(){
					// 百度地图API功能
					var map = new BMap.Map("baidumap");            // 创建Map实例
					var point = new BMap.Point(116.404, 39.915);    // 创建点坐标
					map.centerAndZoom(point,12);                     // 初始化地图,设置中心点坐标和地图级别。
					map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的
					var gc = new BMap.Geocoder();    
					
					//IP定位获取当前城市
					function myFun(result){
					    var cityName = result.name;
					    map.setCenter(cityName);
					}
					var myCity = new BMap.LocalCity();
					myCity.get(myFun);//设置IP定位获取当前城市
					
					map.enableScrollWheelZoom();                            //启用滚轮放大缩小
					map.enableDragging(); //开启拖拽
					map.enableInertialDragging();//启用地图惯性拖拽，默认禁用。
					
					
					map.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP,BMAP_HYBRID_MAP]}));     //2D图，卫星图
					map.addControl(new BMap.MapTypeControl({anchor: BMAP_ANCHOR_TOP_RIGHT}));    //左上角，默认地图控件
					
					map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
					
					//鼠标点击拾取坐标
					map.addEventListener("click", function(e){
					  	$("input[name='parkInfo.longitude']").val( e.point.lng);
					  	$("input[name='parkInfo.latitude']").val(  e.point.lat);
					  	//添加动画标注点
					  	map.clearOverlays();//清除地图上所有覆盖物。
					  	var point = new BMap.Point( e.point.lng, e.point.lat);
						var marker = new BMap.Marker(point);  // 创建标注
						map.addOverlay(marker);              // 将标注添加到地图中
						marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
						
						//反地址解析
						gc.getLocation(point, function(rs){
					        var addComp = rs.addressComponents;
					        $("input[name='parkInfo.addr']").val(addComp.province + " " + addComp.city + " " + addComp.district + " " + addComp.street + "" + addComp.streetNumber);
					    });  
					});
				},3000);
				
				
			});
			
								
		</script>
		
	</body>
</html>